import { createStore } from 'vuex'
import createPersistedState from 'vuex-persistedstate'

import test from './modules/test' // 引入模块

export default createStore({
	plugins: [
		createPersistedState({
			key: `${import.meta.env.VITE_CACHE_PRE}-vuex4-`, // 存储键名
			storage: window.localStorage, // 存储方式
			reducer: (state: any) => {
				// 排除 test1 模块
				const { test1, ...rest } = state
				return rest
			}
		})
	],
	modules: {
		test
	}
})
